home *** CD-ROM | disk | FTP | other *** search
/ Freelog 46 / Freelog046.iso / Alu / Celestia / Win32LoresTex / celestia-lores-win32-1.3.0.exe / {app} / shaders / bumpdiffuse_arb.vp next >
Text File  |  2003-03-05  |  2KB  |  52 lines

  1. !!ARBvp1.0
  2.  
  3. # Compute the surface space light vectors for diffuse bump mapping
  4.  
  5. ATTRIB iPos          = vertex.position;
  6. ATTRIB iNormal       = vertex.normal;
  7. ATTRIB iTangent      = vertex.attrib[6];
  8. ATTRIB iTex0         = vertex.texcoord[0];
  9. ATTRIB iTex1         = vertex.texcoord[1];
  10. PARAM  mvp[4]        = { state.matrix.mvp };
  11. PARAM  lightDir      = program.env[0];
  12. PARAM  half          = 0.5;
  13. OUTPUT oPos          = result.position;
  14. OUTPUT oColor        = result.color;
  15. OUTPUT oTex0         = result.texcoord[0];
  16. OUTPUT oTex1         = result.texcoord[1];
  17.  
  18. TEMP   binormal;
  19. TEMP   t;
  20. TEMP   light_surf;
  21.  
  22. # Transform the vertex by the modelview matrix
  23. DP4   oPos.x, mvp[0], iPos;
  24. DP4   oPos.y, mvp[1], iPos;
  25. DP4   oPos.z, mvp[2], iPos;
  26. DP4   oPos.w, mvp[3], iPos;
  27.  
  28. # Compute the binormal--cross product of tangent and normal
  29. MOV   t, iTangent;
  30. MUL   binormal, iNormal.zxyw, t.yzxw;
  31. MAD   binormal, iNormal.yzxw, t.zxyw, -binormal;
  32.  
  33. # Normalization should not be necessary
  34. #DP3   binormal.w, binormal, binormal;
  35. #RSQ   binormal.w, binormal.w;
  36. #MUL   binormal.xyz, binormal, binormal.w;
  37.  
  38. # Transform the light direction from object space into surface space
  39. DP3   light_surf.x, iTangent, lightDir;
  40. DP3   light_surf.y, binormal, lightDir;
  41. DP3   light_surf.z, iNormal, lightDir;
  42.  
  43. # Compress the light direction to fit in the primary color and output it
  44. MAD   oColor, light_surf, half, half;
  45.  
  46. # Output the texture
  47. MOV   oTex0, iTex0;
  48. MOV   oTex1, iTex1;
  49.  
  50. END
  51.  
  52.